//
//  UIView+SetFrame.m
//  tools
//
//  Created by hyjet on 2018/3/14.
//  Copyright © 2018年 tools. All rights reserved.
//

#import "UIView+SetFrame.h"

@implementation UIView (SetFrame)

-(void)setCw_x:(CGFloat)cw_x
{
    CGRect frame = self.frame;
    frame.origin.x = cw_x;
    self.frame = frame;
}

-(void)setCw_y:(CGFloat)cw_y
{
    CGRect frame = self.frame;
    frame.origin.y = cw_y;
    self.frame = frame;
}

-(void)setCw_width:(CGFloat)cw_width
{
    CGRect frame = self.frame;
    frame.size.width = cw_width;
    self.frame = frame;
}

-(void)setCw_height:(CGFloat)cw_height
{
    CGRect frame = self.frame;
    frame.size.height = cw_height;
    self.frame = frame;
}

-(void)setCw_centerX:(CGFloat)cw_centerX
{
    CGPoint center = self.center;
    center.x = cw_centerX;
    self.center = center;
}

-(void)setCw_centerY:(CGFloat)cw_centerY
{
    CGPoint center = self.center;
    center.y = cw_centerY;
    self.center = center;
}

-(void)setCw_size:(CGSize)cw_size
{
    CGRect frame = self.frame;
    frame.size = cw_size;
    self.frame = frame;
}

-(CGFloat)cw_y
{
    return self.frame.origin.y;
}

-(CGFloat)cw_x
{
    return self.frame.origin.x;
}

-(CGFloat)cw_width
{
    return self.frame.size.width;
}

-(CGFloat)cw_height
{
    return self.frame.size.height;
}

-(CGFloat)cw_centerX
{
    return self.center.x;
}

-(CGFloat)cw_centerY
{
    return self.center.y;
}

-(CGSize)cw_size
{
    return self.frame.size;
}

- (void)alignHorizontal
{
    self.cw_x = (self.superview.cw_width - self.cw_width) * 0.5;
}

- (void)alignVertical
{
    self.cw_y = (self.superview.cw_height - self.cw_height) *0.5;
}

@end
